<template>
  <div>
    <h2>Home组件</h2>
    <button @click="gotoMovie(3)">gotoMovie</button>&nbsp;
    <!-- 命名路由声明式导航 -->
    <router-link :to="{name:'mov',params:{id:3}}">跳转到movie</router-link>
    <!-- 命名路由编程式导航 -->
    <button @click="gotoMovie2(2)">go to Movie2</button>
  </div>
</template>

<script>
export default {
    name:'MyHome',
    methods:{
      gotoMovie(id){
        // 编程式导航到movie3 页面
        this.$router.push('/movie/'+id)
      },
      gotoMovie2(id){
        // 命名路由导航到movie2页面
        this.$router.push({name:'mov',params:{
          id:id
        }})
      }
    }

}
</script>

<style>

</style>